package demo.jdk.features.jdk7;

import java.sql.*;

/**
 * @author Ranchoz  2018/9/9 15:20
 **/
public class SetSchema {
	public void setSchema() throws SQLException {
		try (Connection connection = DriverManager
				.getConnection("jdbc:derby://localhost/java7book")) {
			connection.setSchema("DEMO_SCHEMA");
			try (Statement stmt = connection.createStatement();
			     ResultSet rs = stmt.executeQuery("SELECT * FROM author")) {
				while (rs.next()) {
					System.out.println(rs.getString("name"));
				}
			}
		}
	}
	public static void main(String[] args) {
		SetSchema ss = new SetSchema();
		try {
			ss.setSchema();
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
}
